package cn.edu.sdjzu.xg.eagle.mapper;

import cn.edu.sdjzu.xg.eagle.entities.CommunityActivity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommunityActivityMapper {

    // 添加活动
    @Insert("INSERT INTO CommunityActivity (ActivityID, ActivityName, ActivityLocation, ActivityPlan, ActivityStatus, StartTime, EndTime) " +
            "VALUES (#{activityID}, #{activityName}, #{activityLocation}, #{activityPlan}, #{activityStatus}, #{startTime}, #{endTime})")
    boolean addCommunityActivity(CommunityActivity communityActivity);

    // 修改活动
    @Update("UPDATE CommunityActivity SET " +
            "ActivityName = #{activityName}, " +
            "ActivityLocation = #{activityLocation}, " +
            "ActivityPlan = #{activityPlan}, " +
            "ActivityStatus = #{activityStatus}, " +
            "StartTime = #{startTime}, " +
            "EndTime = #{endTime} " +
            "WHERE ActivityID = #{activityID}")
    boolean updateCommunityActivity(CommunityActivity communityActivity);
    // 删除活动
    @Delete("DELETE FROM CommunityActivity WHERE ActivityID = #{activityID}")
    boolean deleteCommunityActivity(String activityID);


    // 查询活动
    @Select("SELECT " +
            "ActivityID, ActivityName, ActivityLocation, ActivityPlan, ActivityStatus, StartTime, EndTime " +
            "FROM CommunityActivity " +
            "WHERE ActivityID = #{activityID}")
    CommunityActivity findCommunityActivityByActivityID(String activityID);

    // 查询全部活动
    @Select("SELECT " +
            "ActivityID, ActivityName, ActivityLocation, ActivityPlan, ActivityStatus, StartTime, EndTime " +
            "FROM CommunityActivity")
    List<CommunityActivity> findCommunityActivitys();
}